﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	计划工具
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<fieldset><legend>计划工具</legend>
<div style="width:768px; background-color:#FFFFFF;"> 
  <table width="600" align="center" cellpadding="3" cellspacing="1" class="table"> 
  <tr><th colspan="3">万能彩票倍投计算器</th></tr>
  <tr> 
    <td width="99" rowspan="4" align="center">基本设置</td> 
    <td width="158" align="right">&nbsp;方案期数：</td> 
    <td width="319" align="left"><input name="dataInput" type="text" id="sq" value="10" size="8" maxlength="8" /></td> 
  </tr> 
  <tr> 
    <td align="right">&nbsp;投入注数：</td> 
    <td align="left"><input name="dataInput" type="text" id="sz" value="1" size="8" maxlength="8" /></td> 
  </tr> 
  <tr> 
    <td align="right">&nbsp;起始倍数：</td> 
    <td align="left"><input name="dataInput" type="text" id="sb" value="1" size="8" maxlength="8" /> 
    最大倍投不超过： 
      <input name="dataInput" type="text" id="sbMax" value="1000" size="8" maxlength="5" /></td> 
  </tr> 
  <tr> 
    <td align="right">&nbsp;单倍奖金：</td> 
    <td align="left"><input name="dataInput" type="text" id="dj" value="17" size="8" maxlength="8" /> 
    (根据彩种和玩法填写) </td> 
  </tr> 
  <tr> 
    <td rowspan="2" align="center">收益率设置</td> 
    <td align="left"><input name="syType" id="syType1" type="radio" value="0" checked="checked" onclick="changeType()" /><label for="syType1">全程收益率：</label></td> 
    <td align="left"><input name="dataInput" type="text" id="sy1" value="" size="8" maxlength="8" /> 
%</td> 
  </tr> 
  <tr> 
    <td align="left"><input type="radio" name="syType" id="syType2" value="1" onclick="changeType()" /><label for="syType2">前</label> 
      <input name="dataInput" type="text" id="qi" value="5" size="3" maxlength="4" disabled /> 
<label for="syType2">期收益率：</label></td> 
    <td align="left"><input name="dataInput" type="text" id="sy2" value="" size="8" maxlength="8" disabled /> 
  % ，之后收益率：
    <input name="dataInput" type="text" id="sy3" value="" size="8" maxlength="8" disabled /> 
%</td> 
  </tr> 
  <tr> 
    <td height="35" colspan="3" align="center"><input type="button" id="submit" onclick="doClick()" value=" 计 算 " /></td> 
  </tr> 
</table> 
<table width="600" align="center" cellpadding="3" cellspacing="1" id="showTab" class="table"> 
  <tr> 
    <th>期数</th> 
    <th><span class="STYLE1">投入倍数</span></th> 
    <th>本期投入</th> 
    <th>累计投入</th> 
    <th>本期收益</th> 
    <th>盈利收益</th> 
    <th>收益率</th> 
  </tr> 
</table> 
<br /> 
<br /> 
<br /> 
<br /> 
</div> </fieldset>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
<script language="javascript" type="text/javascript">
    function doClick() {
        var bb = document.getElementById("submit");
        var showTab = document.getElementById("showTab");
        bb.value = "正在计算..";
        bb.disabled = true;
        while (showTab.rows.length > 1) showTab.deleteRow(showTab.rows.length - 1); //清空表格
        setTimeout("show();var bb = document.getElementById(\"submit\");bb.disabled = false;bb.value = \" 计 算 \"", 500);
    }

    function show() {
        if (!checkValue()) return;
        var sTr = "";
        var sq = Number(document.getElementById("sq").value);
        var sz = Number(document.getElementById("sz").value);
        var sb = Number(document.getElementById("sb").value);
        var maxBei = Number(document.getElementById("sbMax").value); //合理倍投的最大值
        var dj = Number(document.getElementById("dj").value);
        var qi = Number(document.getElementById("qi").value);
        var syType = (document.getElementById("syType2").checked) ? false : true;
        var sy = (syType) ? Number(document.getElementById("sy1").value) : Number(document.getElementById("sy2").value);
        var showTab = document.getElementById("showTab");
        var baseTr = showTab.rows[0];
        var tempSy;
        var tempTr = 0;
        var thisTr, thisCell;
        var vArr = new Array(7);

        for (var i = 1; i <= sq; i++) {
            if (syType == false && i == (qi + 1)) sy = Number(document.getElementById("sy3").value);
            while (((((dj * sb) - (tempTr + (sz * sb * 2))) * 100) / (tempTr + (sz * sb * 2))) < sy) {
                if (sb > maxBei) {
                    alert("按照当前设置，从第" + i + "期开始，投注倍数将超过" + maxBei + "倍，建议从以下方面调整方案\n\n1.减少方案期数(推荐)\n2.降低预期收益率(推荐)\n3.减少投入注数\n4.提高最大倍数设置");
                    return;
                }
                sb++;
            }
            tempTr += (sz * sb * 2);
            tempSy = ((dj * sb) - tempTr) * 100 / tempTr;
            vArr[0] = i.toString();
            vArr[1] = sb.toString();
            vArr[2] = (sz * sb * 2).toString();
            vArr[3] = tempTr.toString();
            vArr[4] = (dj * sb).toString();
            vArr[5] = ((dj * sb) - tempTr).toString();
            vArr[6] = tempSy.toFixed(2) + "%";
            thisTr = showTab.insertRow(-1);
            for (var ii = 0; ii < baseTr.cells.length; ii++) {
                thisCell = thisTr.insertCell(ii);
                thisCell.className = (i % 2 == 0) ? "itd2" : "itd1";
                thisCell.innerHTML = vArr[ii];
            }
        }
    }
    function changeType() {
        var syType1 = document.getElementById("syType1");
        var sy1 = document.getElementById("sy1");
        var sy2 = document.getElementById("sy2");
        var sy3 = document.getElementById("sy3");
        var qi = document.getElementById("qi");
        sy1.disabled = !syType1.checked;
        sy2.disabled = syType1.checked;
        sy3.disabled = syType1.checked;
        qi.disabled = syType1.checked;
    }
    function checkValue() {
        var showTab = document.getElementById("showTab");
        var inputArr = document.getElementsByName("dataInput");
        var re = /[^\d]+/ig;
        for (var i = 0; i < inputArr.length; i++) {
            if (re.test(inputArr[i].value)) {
                alert("数值必须为正整数");
                inputArr[i].select();
                return false;
            }
        }
        return true;
    }
</script> 
</asp:Content>
